import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

import Models.ChessPieceModel;
import Models.Point2D;
import TechStuff.RmiStarter;

import Controllers.ChessPieceControllerInterface;


public class ChessPieceView
extends RmiStarter implements ChessPieceControllerInterface {
	private ChessPieceControllerInterface controller;
	private String name;

	public ChessPieceView(String name) { 
		super(null); 
		this.name = name;
		doCustomRmiHandling();
		}

	@Override
	public void doCustomRmiHandling() {
		String host = "localhost";
		try {
		    Registry registry = LocateRegistry.getRegistry(host);
		    controller = (ChessPieceControllerInterface) registry.lookup(name);
		} catch (Exception e) {
		    System.err.println("Client exception: " + e.toString());
		    e.printStackTrace();
		}		
	}

	@Override
	public boolean legalMove(Point2D moveVector, ChessPieceModel chessPiece) throws RemoteException {
		return controller.legalMove(moveVector);
	}
	
	@Override

	public boolean legalCapture(Point2D moveVector, ChessPieceModel chessPiece) throws RemoteException{
		return controller.legalCapture(moveVector);
	}
	
	@Override
	public boolean canJumpOverPieces() throws RemoteException {
		// TODO Auto-generated method stub
		return false;
	}
	
	public String getName()
	{
		return name;
	}

	@Override
	public boolean canPieceMoveNotify(Point2D from, Point2D to,
			ChessPieceModel chessPiece) throws RemoteException {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean legalMove(Point2D moveVector, ChessPieceModel chessPiece)
			throws RemoteException {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean legalCapture(Point2D moveVector, ChessPieceModel chessPiece)
			throws RemoteException {
		// TODO Auto-generated method stub
		return false;
	}

	
}
